package com.example.class_manage.Mapper;

import com.example.class_manage.Entity.Homework_text;
import com.example.class_manage.Entity.Howework_pic;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
 * @author Miao-yongzheng
 * @create 2021-11-07 13:48
 */
@Mapper
public interface HomeWork_text_mapper {
    @Select("select * from homework_text")
    List<Homework_text> Test_findAlltext();

    @Update("update homework_text set Answer=#{Answer} where id=#{id}")
    Integer UpdateText_Answer(String Answer,String id);

    @Insert("insert into question_text(id, `describe`,pic) values (#{id},#{descibe},#{Question_img})")
    Integer UploadQuestion(String id, String descibe, byte Question_img[]);//上传作业

    @Select("select * from homework_text where id = #{homework_id}")
    List<Homework_text> Find_Homework_byid(String homework_id);

    @Update("update homework_text set grade = 100 where Id = #{id} and stu_id =#{stu_id}")
    Integer Set_grade100(String id, Integer stu_id);

    @Update("insert into homework_text (id, student_name, Time, stu_id, flag,homework_text) values (#{id},#{student_name},#{Time},#{stu_id},#{flag},#{homework_text})")
    Integer Insert_onerecordtext(String id, String student_name, String Time, String stu_id, String flag, String homework_text);

    @Select("select * from homework_text where mark_flag = #{mark_flag}")
    List<Homework_text> Review_All_text_bymark_flag(String mark_flag);

    @Select("select * from homework_text where mark_flag = 0 and id = #{id}")
    List<Homework_text> Review_All_text_bymark_flag_teacher(String id);


    @Select("select * from homework_text where mark_flag = 2 and id = #{id}")
    List<Homework_text> Review_All_text_bymark_flag_assiatant(String id);


    @Update("update homework_text set mark_flag = #{mark_flag} where  id = #{id}")
    Integer UpHomework_text_mark(String mark_flag, String id);

    @Select("select * from homework_text where stu_id = #{id}")
    List<Homework_text> Review_All_text_bystu_id(String id);

    @Select("select * from homework_text where stu_id = #{stu_id}")
    public List<Homework_text> Find_All_bystu_id_textHomework(String stu_id);

    @Select("select * from homework_text where Flag = 1 and stu_id = #{id}")
    List<Homework_text> Review_text_byFlag(String id);

    @Update("update homework_text set flag = #{flag} where stu_id = #{stu_id} and id = #{id}")
    Integer Update_flag(String flag, String stu_id, String id);
}
